/**
 * @Project TMHSC
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Jan 30, 2011
 * @Createtime 9:35:37 PM
 */

package com.tmh.study.aASA
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	/**
	 * Compare opaque (24 bits) and transparent (32 bits) Bitmap
	 */
	public class BitmapCompare extends Sprite
	{
		public function BitmapCompare():void
		{
			graphics.lineStyle(0);

			// draw bunch of random lines
			for (var i:int = 0; i < 100; i++)
			{
				graphics.lineTo(Math.random() * 300, Math.random() * 400);
			}

			// create opaque bitmap 0xRRGGBB
			var bmpd1:BitmapData = new BitmapData(300, 200, false, 0xffffff);
			bmpd1.fillRect(new Rectangle(100, 50, 100, 100), 0xff0000);
			var bmp1:Bitmap = new Bitmap(bmpd1);
			addChild(bmp1);

			// create transparent bitmap 0xAARRGGBB
			var bmpd2:BitmapData = new BitmapData(300, 200, true, 0x00ffffff);
			bmpd2.fillRect(new Rectangle(100, 50, 100, 100), 0x80ff0000);
			var bmp2:Bitmap = new Bitmap(bmpd2);
			bmp2.y = 200;
			addChild(bmp2);
		}
	}
}